Mapping nanocrystal orientations via scanning Laue diffraction microscopy for multi-peak Bragg coherent diffraction imaging

A workflow for orienting and mapping nanocrystals on a substrate of a different material lattice using scanning Laue diffraction microscopy has been established.

The following document provides supplemental information on the main text. This includes Laue detector calibration using two known Bragg peaks (Appendix A), mathematical determination of the rotation/orientation matrix from a specific set of goniometer angles (Appendix B), detector parameter optimization (Appendix C), demonstration of the twiddle algorithm on parameter optimization for rolling ball algorithm (Appendix D), grain size distribution (Appendix E), an example of using rolling ball algorithm with different radius (Appendix F), and high-resolution SEM images for crystals (Appendix G).

S1. Laue detector calibration using two known Bragg peaks
For the detector calibration we used a [001]-oriented Silicon wafer. The crystal orientation matrix was analytically derived by creating orthogonal vector bases in the crystal, sample, and laboratory frames and measuring two independent Bragg reflections with known Miller indices, which in turn, will define two vectors in the crystal and laboratory frames. An initial list of Miller indices was generated for all the peaks that are predicted to appear on the detector. The coordinates of each peak on the detector are calculated by forward modeling the diffraction patterns in Laue geometry at the beamline's experimental setup (Ploc, 1983). Finally, we optimize the detector parameters, which consist of two three-component Rodrigues rotation and translation vectors (Randle & Day, 1993), by minimizing the average distance of each simulated peak on the detector from the experimentally observed peaks on the measured Laue patterns using a direct-search method used for non-linear problems with multiple variables (Nelder & Mead, 1965;Spendley et al., 1962).
We measured the (11 ‾ 1 ‾ ) and (22 ‾ 0) Bragg reflections by rotating the sample to specific , , angles determined in the laboratory frame where the peak intensity of each Silicon Bragg peak was maximized. Fig. 1(b) in the main manuscript shows the crystal unit cell and crystallographic planes, which satisfy the Bragg condition for the (22 ‾ 0) and (11 ‾ 1 ‾ ) reflections. Each 11 ‾ 1 ‾ lab and 22 ‾ 0 lab vector is perpendicular to the indicated family of atomic planes when the Bragg condition is satisfied for one set of planes, thus, during two different and independent measurements. The x-ray beam is propagating along the axis, with the axis pointing up, and the axis pointing outward from the storage ring.
Then, we constructed orthonormal vector bases in the three different reference frames and derived the matrices that transform a vector expressed in one reference frame to another (the derivation of transformation matrix is given in Appendix B). In three-dimensional space the term orthonormal refers to any set of unitary vectors, which are normal to each other (Koks, 2006). A set of orthonormal, thus, linearly independent vectors compose a vector basis. Any arbitrary vector can be expressed as a linear combination of the base vectors.
For each Bragg reflection, we can calculate the 11 ‾ 1 ‾ l , 22 ‾ 0 l vectors, which are given by since the incident x-rays are parallel to the axis of the laboratory frame and = 2 ( cos sin sin cos cos with , the detector angles as depicted in Fig. 1(a) of the main manuscript and the x-ray wavelength.
Since we also know the Miller indices of the two measured Bragg peaks (11 ‾ 1 ‾ ), (22 ‾ 0), we can calculate the families of atomic planes. The difference between the and 1 vectors correspond to a vector, which is perpendicular to the and 1 vectors as shown in Fig. S1.

Figure S1
Construction of a vector basis from two known vectors.
We pick the third linearly independent vector to be the cross product of the two vectors. Thus, we have 2 = − 1 and 3 = 1 × 2 (6) Then, by normalizing the 1 , 2 , 3 vectors we create a vector basis in the crystal frame, shown in Fig. S1 We can easily derive the following relations between the , , and matrices: The transformation matrix B translates the crystal orientation in the crystal frame to an orientation in the sample frame, which can be described in principle, by two in-plane and out-of-plane vectors. In the laboratory frame, by definition = 0, = 90 ∘ , and = 0. Thus, to simulate any Laue pattern, which is acquired at a specific set of goniometer angles one must consider the rotation of the sample to that set of angles. The determination of rotation matrix from a set of goniometer angles is mentioned Appendix B. The incident beam is parallel to ℓ , ℓ is up and ℓ chosen to form a right-hand system. At the APS, ℓ points outwards of the experimental hutch, ℓ = ℓ × ℓ . The sample frame provides a basis in which to represent a uniquely oriented crystal specimen. For an arbitrarily oriented sample, coordinates in { , , } are related to { ℓ , ℓ , ℓ } via the rotation matrix (the sample frame w.r.t. the Lab frame) : Then, we need to define the conventional Bunge-style orientation matrix for the crystal with respect to the sample reference frame. If we have a set of Bunge Euler angles (in our case, single-crystal (001)-oriented Silicon is 1 = 0, = 0, 2 = 0), we can obtain the orientation matrix in Appendix B. With the knowledge of two sets of goniometer angles 1 , 1 , 1 , 2 , 2 , 2 , we can get the rotation matrix 1 and 2 by Equation 14. We can apply the rotation matrix 1 and 2 and the orientation matrix to the corresponding 22 ‾ 0 l , 11 ‾ 1 ‾ l , which relates the vectors in the lab frame (e.g., a diffracted beam arriving on the Bragg detector, or on the Laue detector) to crystal directions. Combining Error! Reference source not found., Error! Reference source not found., and Error! Reference source not found., we can fully constrain the orientation of the crystal with respect to the lab frame. This method determines the orientation of the substrate in the lab reference frame. In order to simulate the Laue pattern on the detector, we not only need the orientation matrix of substrate in the lab frame, but also the translation vector and the rotation matrix for the detector in the lab frame.
We define the vector as a conversion vector, coordinates in { , , } are connected to { ℓ , ℓ , ℓ } via the rotation matrix and translation vector . we use the following equation to calculate the coordinates of on the detector: The rotation matrix can be defined in a similar way According to Error! Reference source not found. and Appendix B, we get the rotation matrix : Then, the detector parameters will be optimized by the methods in Appendix C.

S2. Mathematical determination of rotation/orientation matrix from a set of specific set of goniometer angles
The lab frame is intended to provide a global reference frame that is stationary during the experiment. With regards to the geometric construction, we define the incident beam to be parallel to ℓ , ℓ is up and ℓ chosen to form a right-hand system (at the APS, ℓ points out the door of the hutch), ℓ = ℓ × ℓ . The sample frame provides a basis in which to represent a uniquely oriented and located specimen. For the arbitrarily defined sample- .
Combining Equation 14 and Equation 21, we can get the rotation matrix .

S3. Detector parameter optimization
The Laue detector parameters include the rotation vector and translation vector , both of which contain three degrees of freedom. The translation vector gives the distance between the center of the detector and the origin in the laboratory frame. The rotation vector is the Rodriguez rotation vector, which rotates the detector from the origin to its actual location during the measurement. We determined the translation vector to  Figure   S2 (a).
We then optimized the detector parameters by combining the Nelder-Mead algorithm with a grid search method. For the definition of the cost function, we used the forward model to simulate Laue diffraction, compared the simulation and experiment data, and calculated the average distances between the extracted peaks in the experiment data and corresponding nearest peak positions in the forward model. Providing the segmentation result from the experimentally measured Laue pattern of the substrate, we could locate the center-of-mass for each peak. We created a list of Miller indices for each experimentally measured Bragg peak and then found the nearest peak predicted by the forward model. The cost function calculates the average distance between the experimentally measured Bragg peaks and the corresponding nearest peaks predicted by the forward model.
Although Nelder-Mead tends to optimize the objective function fairly fast, within tens of iterations, it can be trapped in valleys around local minima. Considering this, we decided to set a few initial points for the optimization. More specifically, we picked three different values as the initial point for each of the three components of the translation vector 0 . We were able to find the optimal value of the 0 component of the translation vector and with the same procedure determined the values of the other components of the translation vector and rotation vector . Combining Nelder-Mead with a grid search method can solve the problem of multi-variable optimization, shown before and after in Figure S2. The values of all six components of the two vectors are listed in Table S1.

S4. Demonstration of the twiddle algorithm on parameter optimization for rolling ball algorithm
Twiddle algorithm (https://martin-thoma.com/twiddle/) is used to search for the parameter in rolling ball algorithm (RB). A twiddle algorithm is a generic algorithm for optimizing loss functions for single values. Compared with gradient descent method, it is superior regarding to the time complexity, because of no calculation requirement for the second order derivative.
The input of twiddle algorithm is an objective function ( ) that calculates the gradient checkpoint at (derivative ⁄ in 2.3 Image processing). At the beginning of twiddle refinement, we run RB algorithm with 0 (the initial point for optimizing): ( ) * = ( 0 ). We set range for the radius, and the as tolerance to determine the convergence of the gradient. Then we add initial (increment of radius) to , and re-calculate the objective function ( ); if there was some improvement ( ( ) < ( ) * ), then we increase the increment of radius * = 1.1 and update the optimal function value ( ) * = ( ). Otherwise, we try to decrease the radius , and this means −= 2 * , recalculate the ( ) and compare ( ) and ( ) * again. If there is some improvement, then this means we should decrease . Thus, we adaptively changed the decrement ( * = 1.05) based on the performance of new parameters. If there is no improvement, this means neither increment nor decrement improves the searching, the step size might simply be too big. Therefore, we adjust the extent of increment/decrement * = 0.95 and iteratively run the same procedure. The whole process terminates only when reaches a set threshold (usually 0.1) or radius is out of range (usually 10 pixels ~ 150 pixels).

Figure S3
Pseudo-code of twiddle algorithm for parameter optimization.

S5. Grain size distribution
The grain size distribution is generated by MTEX (https://mtex-toolbox.github.io/ShapeParameters.html). The input is sample EBSD data set and we remove all not indexed pixels and reconstruct grains followed by computing the number of pixels that belong to a certain grain. The grain area represents the actual area measured in 2 . We analyze the distribution of grains by grain area using a histogram plotted in Figure S4.

S8. Determination of the radius parameter of RBA
The ball radius is the only algorithmic parameter in RBA but its value depends on the background distribution found in each experimentally acquired image. The ball radius value controls which features are left out and which are kept. Accordingly, a routine for optimizing the RBA radius for each acquired Laue pattern was established and is described below. The radius is selected to be appreciably wider than any of the apparent diffraction spots that resemble and could be falsely classified as Bragg peaks. However, the ball radius is small enough to follow the smoothly varying background and correctly subtract it. The twiddle algorithm, Appendix D (Thoma, 2014), is used to find the best RBA radius. The objective or cost function was chosen to be the derivative of the fraction of pixels whose intensities are below a threshold value in the corrected image (raw image with background subtracted) with respect to the tested radius. When the radius value is too small, the derivative ⁄ is large because increasing the radius rapidly increases the number of peaks. According to the distribution of pixel intensities, most false positives are low in intensity. When the radius is less than two pixels, the rolling ball enters the interior of all false positives. In this situation, a small increase in radius will lead the ball to fail to enter a large number of low-intensity false positives. Therefore, there is a rapid increase of pixels classified as peaks with intensities over 10 counts/pixel in the corrected image. The derivative ⁄ reaches its minimum point where the substrate peaks, each consisting of many high-intensity pixels, are included as peaks. At this point, further increases in radius do not rapidly increase the number of peaks found. Thus, more peaks are found that are false positives (with respect to nanocrystal peaks) and the derivative increases. Thus, there is a plateau (minimum) in the number of peaks with respect to the radius that allows the objective function to identify the best value.
The initial value of radius was 20 and the allowed range of radii values is [10,200]. The tolerance (the number used to determine when optimization has converged to a sufficiently good score) is 1 pixel. Finally, the best radius returned by the optimization for the current dataset was 90 pixels. To justify that 90 is a reasonable number, Fig. 4(b) shows the number of pixels whose intensities are above a threshold value in the corrected image with radii ranging from 0.1 to 300 pixels. The fraction of pixels F whose intensity is larger than the threshold value 10 and the derivative ∂F⁄∂r of the fraction of pixels with respect to the tested radius is calculated and shown in Fig. 4(b). The substrate peaks were then segmented from the residual noise through a global threshold τ whose value was determined by minimizing ∂F⁄∂r, as in the RBA radius optimization. Using a cluster identification algorithm (Virtanen et al., 2020), the location of all intensity clusters (substrate peaks) was identified.
The final values obtained from different initial guesses are not consistent. As an illustration, we compared the outcomes determined from varying initial values of 2 , where the initial value ranges from -20 to -30 mm in increments of 2. For each initial value, we generated one Laue pattern and chose ten Bragg peaks from each pattern. We compared these peaks with experimentally measured peaks and then computed the average distance between the extracted and corresponding nearest peak positions provided by the forward model for each Laue pattern. This average distance is known as the loss, which can be optimized using the Nelder-Mead algorithm.

S9. Loss and a standard deviation for the results determined from different starting guesses for .
The final values obtained from different initial guesses are not consistent. As an illustration, we compared the outcomes determined from varying initial values of 2 , where the initial value ranges from -20 to -30 mm in increments of 2. For each initial value, we generated one Laue pattern and chose ten Bragg peaks from each pattern. We compared these peaks with experimentally measured peaks and then computed the average distance between the extracted and corresponding nearest peak positions provided by the forward model for each Laue pattern. This average distance is known as the loss, which can be optimized using the Nelder-Mead algorithm.
The subsequent table displays the loss for the results obtained from different starting guesses for 2 , and the optimized values of 1 , 2 , and 3 for the corresponding initial guesses. The variance ( 2 ) can be calculated using the following equation, where is the standard deviation. Here each of the independent observations is the average distance calculated from the ten peaks of one Laue pattern defined as loss, and ̅ is the average loss value for the six Laue patterns (N=6). Thus, for the tabulated values below we have an average loss value of 1.4 ± 0.8 pixels.

S10. Pole figures of crystals from EBSD and Laue
In order to illustrate the randomness of the misorientations, we show multiple examples of combined pole figures (PFs) of different crystals from EBSD (blue points in the figure below) and Laue (orange points in the figure below) and find that the discrepancy of orientations (misorientations) from the two analysis lacks any systematic pattern, i.e., there is no systematic offset between the Laue and EBSD measurements of orientation. We plot and show all 19 PFs below for illustration.